﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;

using System.IO;
using System.Collections;
using System.Data.OleDb;


namespace Cisoft.Cisoft3G.DAL
{
    /// <summary>
    /// 数据访问类ImportDO。
    /// gwh 2009-05-19
    /// </summary>
    public class ImportDO
    {
        public ImportDO()
        { }
        #region  成员方法

       


        #region 读取Excel
        public DataSet GetDataSetBySqlExcel(string strPath, string sql)
        {
            try
            {

                //strPath即是excel文档的路径。

                string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + strPath + ";Extended Properties=Excel 8.0;";

                //Sheet1为excel中表的名字
                //string sql = "select * from ["Sheet1$]";

                OleDbCommand cmd = new OleDbCommand(sql, new OleDbConnection(conn));
                OleDbDataAdapter ad = new OleDbDataAdapter(cmd);
                DataSet ds = new DataSet();
                ad.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                return null;
            }
        }
        #endregion



        #endregion  成员方法
    }
}
